import request from '@/utils/request'
import {
  renderUrl
} from '../utils'

const headers = {
  'Content-Type': 'application/json'
}

export function add(data) {
  return request({
    url: '/banner',
    method: 'POST',
    data: JSON.stringify(data),
    headers
  })
}

export function edit(data) {
  return request({
    url: '/banner',
    method: 'PUT',
    data: JSON.stringify(data),
    headers
  })
}

export function del(data) {
  return request({
    url: `/banner/${data.countryId}/${data.platform}/${data.id}`,
    method: 'DELETE',
    headers
  })
}

export function getCouponDetail(data) {
  return request({
    url: renderUrl('/coupon/{id}', data),
    method: 'get'
  })
}
export function getmyCentre() {
  return request({
    url: '/myCentre/relations',
    method: 'get'
  })
}
export function getDiscount() {
  return request({
    url: '/admin/wallet/getDiscount',
    method: 'GET'
  })
}
export function getCouponList(data) {
  return request({
    url: '/coupon/list',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export function grant(data) {
  return request({
    url: '/coupon/couponHistory/grant',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export function countryList(data) {
  return request({
    url: '/banner/countryList',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export default {
  add,
  edit,
  del
}
